package com.kkb.controller;

import com.kkb.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class TeamController {

    @Autowired
    private TeamService service;

    @RequestMapping("hello.do")
    public ModelAndView add(){
        System.out.println("TeamController--------Add--------");
        service.add();
        ModelAndView mv = new ModelAndView();
        //等价于保存页面参数值request.setAttrubuite("teamName","湖人");
        mv.addObject("teamName","湖人");
        //等价于页面的转发 request.getRequestDispatcher("index.jsp").forward(request,response);
        mv.setViewName("index");

        //经过InternalResourceViewResolver对象的处理之后加上前后缀就变为了 /index.jsp
        return mv;

    }


}
